﻿#region references

using System.IO;
using NUnit.Framework;
using SpoolFileLibrary.Reader;

#endregion

namespace SpoolFileReader.Test {
    [TestFixture]
    public class SpoolFileReaderTest {
        private const string TESTDATA_DIR = @"..\..\..\TestData\";

        [Test]
        public void OpenEMFSpoolFileWithoutThumbnails() {
            string emfDir = Path.Combine(TESTDATA_DIR, "EMF");
            string emfFile = Path.Combine(emfDir, "00022.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(emfFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile();
            Assert.IsTrue(spoolFileData.Pages.Count == 9);
        }

        [Test]
        public void OpenEMFSpoolFile13()
        {
            string emfDir = Path.Combine(TESTDATA_DIR, "EMF");
            string emfFile = Path.Combine(emfDir, "00013.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(emfFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile();
            Assert.IsTrue(spoolFileData.Copies == 7);
        }

        [Test]
        public void OpenEMFSpoolFile170() {
            string emfDir = Path.Combine(TESTDATA_DIR, "EMF");
            string emfFile = Path.Combine(emfDir, "00170.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(emfFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile();
            Assert.IsTrue(spoolFileData.Copies == 7);
        }

        [Test]
        public void OpenEMFSpoolFileWithThumbnails() {
            string emfDir = Path.Combine(TESTDATA_DIR, "EMF");
            string emfFile = Path.Combine(emfDir, "00022.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(emfFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile(true, 10);
            Assert.IsNotNull(spoolFileData.Pages[0].PageImage);
        }


        [Test]
        public void OpenHPGLSpoolFileWithoutThumbnails() {
            string hpglDir = Path.Combine(TESTDATA_DIR, "HPGL");
            string hpglFile = Path.Combine(hpglDir, "00006.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(hpglFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile();
            Assert.IsTrue(spoolFileData.Pages.Count == 0);
            Assert.AreEqual(spoolFileData.Copies, 1);
        }

        [Test]
        public void OpenPCLSpoolFileWithoutThumbnails() {
            string pclDir = Path.Combine(TESTDATA_DIR, "PCL");
            string pclFile = Path.Combine(pclDir, "00010.SPL");
            var spoolFileReader = new SpoolFileLibrary.Reader.SpoolFileReader(pclFile);
            ISpoolFile spoolFileData = spoolFileReader.ParseSpoolFile();
            Assert.IsTrue(spoolFileData.Pages.Count == 0);
            Assert.AreEqual(spoolFileData.Copies, 77);
        }
    }
}